package todolist.entity;

import com.sun.speech.freetts.VoiceManager;

/**
 * Text-to-speech Entity. Provides 2 functions to convert strings of text to speech.
 */

public class TTSEntity {

	private String strVoiceName;
	private com.sun.speech.freetts.Voice systemVoice;

	public TTSEntity(String pstrVoiceName) {
		strVoiceName = pstrVoiceName;
		systemVoice = VoiceManager.getInstance().getVoice(strVoiceName);
		systemVoice.allocate();
	}

	public void say(String[] pstrSpeech) {
		for (int i = 0; i < pstrSpeech.length; i++) {
			say(pstrSpeech[i]);
		}
	}

	public void say(String pstrSpeech) {
		systemVoice.speak(pstrSpeech);
	}

	public void dispose() {
		systemVoice.deallocate();
	}

}
